package com.tengju.data.infrastructure.repository.clickhouse.convert;

import com.tengju.data.domain.model.clickhouse.star.StarChangeNoticeRecord;
import com.tengju.data.domain.model.clickhouse.star.StarChangeNoticeType;
import com.tengju.data.domain.model.user.StarLevelEnum;
import com.tengju.data.domain.model.user.StarRoleEnum;
import com.tengju.data.domain.model.user.UserIdCode;
import com.tengju.data.infrastructure.persistence.mybatis.dataobject.StarChangeNoticeRecordDO;

import java.time.LocalDate;

/**
 * @author chenhang
 * @Date 2021/3/26
 */
public class StarConvert {

    public static StarChangeNoticeRecord toStarChangeNoticeRecordDO(StarChangeNoticeRecordDO starChangeNoticeRecordDO) {
        return new StarChangeNoticeRecord(
                UserIdCode.of(starChangeNoticeRecordDO.getIdCode()),
                StarRoleEnum.parseByRole(starChangeNoticeRecordDO.getBeforeStarRole()),
                StarLevelEnum.parseByStarLevel(starChangeNoticeRecordDO.getBeforeStarLevel()),
                StarRoleEnum.parseByRole(starChangeNoticeRecordDO.getTargetStarRole()),
                StarLevelEnum.parseByStarLevel(starChangeNoticeRecordDO.getTargetStarLevel()),
                StarChangeNoticeType.getByType(starChangeNoticeRecordDO.getChangeType()),
                LocalDate.parse(starChangeNoticeRecordDO.getNoticeDate())
                );
    }
}
